BinarySearch Method (T, IComparer)

Wintellect PowerCollections

Collapse imageExpand ImageCollapseAll imageExpandAll imageDropDown imageDropDownHover imageCopy imageCopyHover image
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Searches a sorted list for an item via binary search. The list must be sorted by the ordering defined by the passed IComparer<T> interface; otherwise, incorrect results will be returned.

Namespace: Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax

C#
public int BinarySearch(
	T item,
	IComparer<T> comparer
)
Visual Basic (Declaration)
Public Function BinarySearch ( _
	item As T, _
	comparer As IComparer(Of T) _
) As Integer
Visual C++
public:
int BinarySearch (
	T item, 
	IComparer<T>^ comparer
)

Parameters

item
T
The item to search for.
comparer
IComparer<(Of <T>)>
The IComparer<T> interface used to sort the list.

Return Value

Returns the index of the first occurence of item in the list. If the item does not occur in the list, the bitwise complement of the first item larger than item in the list is returned. If no item is larger than item, the bitwise complement of Count is returned.

See Also